UNAME=`uname`
if [ "$UNAME" = "Linux" ]; then
	size=$(stat -c%s "../target/boot_s1.bin")
elif [ "$UNAME" = "FreeBSD" ]; then
	size=$(stat -f %z "../target/boot_s1.bin")
else
	echo "Unsupported platform!"
	exit 1
fi

size=$(echo "(( $size + 511 ) / 512)" | bc)
nasm boot_sect.asm -o ../target/boot_sect.bin -f bin \
	-DSTAGE1_SECT_COUNT=$size \
	-DSTAGE1_SECT_OFFSET=0x1 \
	-DSTAGE1_START=0x8000
./sign.pl ../target/boot_sect.bin
echo $size > ../target/boot_s1_size
